#Shader Vertex

#version 330 core

layout (location=0) in vec3 position;
layout (location = 1) in vec3 normal;
uniform mat4 view;
uniform mat4 model;
uniform mat4 projection;

out vec3 fragPos;
out vec3 normalVector;

void main(){
    gl_Position = projection*view* model *vec4(position,1.0f);
    fragPos = vec3(model * vec4(position,1.0));
    normalVector = normal;
}

#Shader Fragment

#version 330 core

out vec4 color;

in vec3 fragPos;
in vec3 normalVector;
uniform vec3 lightPos;
float ambientStrength  = 0.3;
uniform vec3 objectColor;
uniform vec3 lightColor;

vec3 normal = normalize(normalVector);
vec3 lightDir = normalize(lightPos - fragPos);
float diff = max(dot(normal, lightDir), 0.0);

vec3 diffuse = diff * lightColor;


vec3 ambient = ambientStrength*lightColor;
vec3 result = (ambient+diffuse)*objectColor;


void main(){
    color = vec4(result, 1.0);
}